import { useStore } from "@/store"
import { Ref } from "vue-demi"

function useStartEdit(btnLoading: Ref<boolean>) {
  const store = useStore()
  // 开始编辑事件
  const startEdit = async () => {
    btnLoading.value = true
    await store.dispatch("editor/startEdit", {
      fileId: store.state.markdown.id,
      userId: store.state.user.id,
      name: store.state.user.name,
    })
    btnLoading.value = false
  }
  return { startEdit }
}
export default useStartEdit
